package day07;

import java.util.Arrays;

public class BubleDemo {
    public static void main(String[] args) {
        int[] arr ={5,4,3,2,1};
        System.out.println("原数组"+ Arrays.toString(arr));
        // 23,3
        // 23,45,2    23 ,2,45  2,23,45
        //23,3,25,1   3,23,25,1  3,23,1,25  3,1,23,25 1,3,23,25
        //int[] arr ={2,43};
        for (int j = 0; j < arr.length; j++) {
            for(int i=0;i<arr.length-1-j;i++){
                if(arr[i]>arr[i+1]){
                    int temp =arr[i];
                    arr[i] = arr[i+1];
                    arr[i+1] = temp;
                }
                System.out.println("---------比较"+i+"次后数"+Arrays.toString(arr));
            }
            System.out.println("排序"+j+"次后数组"+ Arrays.toString(arr));
        }


    }
}
